Workflow Architecture
Overview of the ValkyrAI workflow engine, covering core runtime, scheduling, events, state, and branching.
- Engine: Asynchronous execution with Quartz scheduling and event triggers.
- Tasks: Ordered sets of modules (adapters) with optional parallel groups.
- Modules: Spring components with a simple execute() contract; Map-based variants can exchange state.
- State:
WorkflowStateas durable context; modules read/write via map I/O. - Branching: Modules implement
BranchingModulesignaling DEFAULT | CONDITIONAL | FAILURE.
Key packages
valkyrai/src/main/java/com/valkyrlabs/workflow/service/ValkyrWorkflowService: Orchestration, scheduling, branching..../modules: Concrete adapters including LLM, REST, Files, Email..../engine/conditions: Condition evaluation (OpenXLS-ready + JEXL fallback)..../events: Event bus and trigger registry.
Parallel execution
- Mark modules with
{"parallel": true, "parallelGroup": "A"}inmoduleDatato run as a batch. - Aggregated outcomes prioritize FAILURE > CONDITIONAL > DEFAULT.
Branching modules
- Implement
BranchingModuleand return aBranchOutcome. FormulaBranchingModuleevaluates spreadsheet-like conditions and can direct to a specific next task (vianextTaskId).
Security context
-
Workflows run under a role (SYSTEM, ASSISTANT, USER). See
runAsWorkflowRolein the service. -
Graph-driven next steps
-
The Workflow Builder saves edges into
workflow.metaas:{ "graph": { "edges": [{ "sourceTaskId": "...", "targetTaskId": "..." }] } }
-
The engine consults this graph first to select the next task, falling back to list order when no edge is found.